/************************************************************************/
/*    Author: Scott Bevin                                           */
/************************************************************************/

#pragma once


#include "../XDelegates/Event.h"
#include <Ogre.h>
#include "DebugMessages.h"

namespace XF
{
	class Logger : public DebugDisplay
	{
	private:
		bool mLogToFile, mLogToCout;
		static Logger *mInstance;
		std::ofstream mFile;

		Logger(){}

		bool OpenFile(std::string file);
		void CloseFile();

		void PrintMessageToFile(std::string message);

	public:
		static Logger *GetInstance();
		~Logger(){}

		XF::Event1<void, std::string> OnLogMessage;

		void EnableLogToFile(std::string file){ mLogToFile = OpenFile(file); }

		void Log(std::string message);

		void ShutDown(){CloseFile();}
	};

	
}

#define XF_LOGGER XF::Logger::GetInstance()

#define COMMENT SLASH(/)
#define SLASH(s) /##s

#if defined _DEBUG
#define DLOG XF::DebugMessage(XF_LOGGER) 
#else
#define DLOG COMMENT
#endif

#if defined XF_FULL_LOGGING
#define LOG XF::DebugMessage(XF_LOGGER) 
#define ILOG XF::DebugMessage(XF_LOGGER)
#define SSELOG XF::DebugMessage(XF_LOGGER)
#elif defined XF_IMPORTANT_MESSAGE_LOGGING
#define LOG COMMENT
#define ILOG XF::DebugMessage(XF_LOGGER)
#define SSELOG XF::DebugMessage(XF_LOGGER)
#else
#define LOG COMMENT 
#define ILOG COMMENT
#define SSELOG XF::DebugMessage(XF_LOGGER)
#endif



